<?php
require_once 'models/zone_geographique.php';
echo '<h3>Population moyenne :</h3>';
if(isset($population)) {
	echo '<p>' . $population . '</p>';
}

echo '<h3>Dates de création :</h3>';
if(isset($creations)) {
	echo '<ul>';
	foreach($creations as $d)
	{
		echo '<li>'. $d->get_date();
		if($admin && $d->get_reference() != 1) {
			echo '<form action="?section=entite_historique&action=delete_date" method="post" class="formsuppr">';
			echo '<input type="hidden" name="id" value="' . $entite->get_identite() . '">';
			echo '<input type="hidden" name="iddate" value="' . $d->get_iddate() . '">';
			echo '<button type="submit" class="btnsuppr">Supprimer</button>';
			echo '</form>';			
		}
		echo '</li>';
	}
	echo '</ul>';
	if($admin) {
		echo '<form action="?section=entite_historique&action=add_creation" method="post">';
		echo '<input type="hidden" name="id" value="' . $entite->get_identite() . '">';
		echo '<label for="creation">Nouveau (jj/mm/saaaa): </label>';
		echo '<input type="text" name="creation" id="creation"/>';
		echo '<button type="submit">Ajouter</button>';
		echo '</form>';
	}
}

echo '<h3>Dates de dissolution :</h3>';
if(isset($dissolutions)) {
	echo '<ul>';
	foreach($dissolutions as $d)
	{
		echo '<li>'. $d->get_date();
		if($admin && $d->get_reference() != 1) {
			echo '<form action="?section=entite_historique&action=delete_date" method="post" class="formsuppr">';
			echo '<input type="hidden" name="id" value="' . $entite->get_identite() . '">';
			echo '<input type="hidden" name="iddate" value="' . $d->get_iddate() . '">';
			echo '<button type="submit" class="btnsuppr">Supprimer</button>';
			echo '</form>';			
		}
		echo '</li>';
	}
	echo '</ul>';
	if($admin) {
		echo '<form action="?section=entite_historique&action=add_dissolution" method="post">';
		echo '<input type="hidden" name="id" value="' . $entite->get_identite() . '">';
		echo '<label for="dissolution">Nouveau (jj/mm/saaaa): </label>';
		echo '<input type="text" name="dissolution" id="dissolution"/>';
		echo '<button type="submit">Ajouter</button>';
		echo '</form>';
	}
}

echo '<h3>Zonnes Occupées :</h3>';
echo '<ul>';
foreach($zones_occ as $z) {
	$debut = $z->get_debut()->get_date();	
	$fin = $z->get_fin()->get_date();
	
	echo '<li>' . $z->get_nomzonegeo();
	if($debut != "" || $fin != "") {
		if($debut == "") $debut = "?";
		else if($fin == "") $fin = "?";
		echo ' (du ' . $debut . ' au ' . $fin . ')';
	}
	if($admin) {
		echo '<form action="?section=entite_historique&action=delete_zone" method="post" class="formsuppr">';
		echo '<input type="hidden" name="id" value="' . $_GET['id'] .'">';
		echo '<input type="hidden" name="zone" value="' . $z->get_idzoneocc() .'">';
		echo '<button type="submit" class="btnsuppr">Supprimer</button>';
		echo '</form>';
	}
	echo '</li>';
}
echo '</ul>';
if($admin) {
	echo '<form action="?section=entite_historique&action=add_zone" method="post">';
		echo '<input type="hidden" name="id" value="' . $_GET['id'] .'">';
		echo '<fieldset><legend>Ajout :</legend>';
			echo '<label for="zone">Territoire : </label>';
			echo '<select name="zone" id="zone">';
			foreach($zones as $z) {
				echo '<option value="' . $z->get_idzonegeo() . '">' . $z->get_nomzonegeo() . '</option>';
			}
			echo '</select><br>';
			
			echo '<label for="debut">Début occupation (jj/mm/saaaa) :</label>';
			echo '<input type="text" name="debut" id="debut"><br>';
			echo '<label for="fin">Fin occupation (jj/mm/saaaa) :</label>';
			echo '<input type="text" name="fin" id="fin"><br>';
			echo '<button type="submit">Ajouter</button>';
		echo '</fieldset>';
	echo '</from>';
}
?>